package com.study.servlet.admin;


import com.alibaba.fastjson.JSON;
import com.study.dao.AwardInfoDAO;
import com.study.dao.CountryInfoDAO;
import com.study.dao.impl.AwardInfoDAOImpl;
import com.study.dao.impl.CountryInfoDAOImpl;
import com.study.dto.AwardDto;
import com.study.pojo.AwardInfo;
import com.study.pojo.CountryInfo;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @PackgeName: com.study.servlet.admin
 * @ClassName: CountryListServlet
 * @Author: 严志祥
 * Date: 2022-05-05 12:08
 * project name: web_project_medal
 * @Version:
 * @Description:
 */
@WebServlet("/admin/award-list.let")
public class AwardListServlet extends HttpServlet {
    private AwardInfoDAO dao = new AwardInfoDAOImpl();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.reset();
        resp.setContentType("application/json;charset=UTF-8");
        try{
//            List<AwardInfo> list = dao.select(0, 5);
            List<AwardDto> list = dao.selectMap(0,999);
            resp.getWriter().print(JSON.toJSON(list));
        }catch (Exception e){
            throw new ServletException(e.getMessage(),e);
        }
        resp.flushBuffer();
    }
}
